﻿/*
 * OStringStream.h
 *
 *  Created on: 2011/05/28
 *      Author: naoki
 */

#ifndef INCLUDED_NTENGINE_OSTRINGSTREAM_H
#define INCLUDED_NTENGINE_OSTRINGSTREAM_H

#include "NTEngine/Base/Array.h"
#include <string>

namespace NTEngine {
using namespace std;

class RefString;

/**
 * @brief 文字列ストリーム
 */
class OStringStream {
public:
	OStringStream( int blockSize = 1024 );
	~OStringStream();
	int precision( int );
	OStringStream& operator<<( char );
	OStringStream& operator<<( unsigned char );
	OStringStream& operator<<( int );
	OStringStream& operator<<( unsigned );
	OStringStream& operator<<( short );
	OStringStream& operator<<( unsigned short );
	OStringStream& operator<<( float );
	OStringStream& operator<<( double );
	OStringStream& operator<<( const string& );
	OStringStream& operator<<( const char* );
	OStringStream& operator<<( char* );
	OStringStream& operator<<( const RefString& );
	OStringStream& operator<<( OStringStream& ( *f )( OStringStream& ) );
	void write( const char*, int size );
	template< class T > void write( const T& ); //バイナリ書き込み
	OStringStream& endl();
	OStringStream& hex();
	OStringStream& dec();

	void get( Array< char >* ) const;
	void get( string* ) const;
	int size() const;
	void clear();
private:
	OStringStream( const OStringStream& ); //コピーコンストラクタ禁止
	void operator=( const OStringStream& ); //代入禁止
	class Impl;
	Impl* mImpl;
};

OStringStream& endl( OStringStream& );
OStringStream& hex( OStringStream& );
OStringStream& dec( OStringStream& );

} // namespace NTEngine
#include "NTEngine/Base/Impl/OStringStreamImpl.h"

#endif // INCLUDED_NTENGINE_OSTRINGSTREAM_H
